package scripting.example1;

/**
 * @Author: webmaster@pavel-kaminsky.com
 * @Date: 31/08/11
 */

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.File;

public class EvaluateFile {
    public static void main(String[] args) throws Exception {

        // create a script engine manager
        ScriptEngineManager factory = new ScriptEngineManager();

        // create JavaScript engine
        ScriptEngine engine = factory.getEngineByName("JavaScript");

        //passing parameters into script language
        String name = "Pavel Kaminsky";
        engine.put("name",name);

        // evaluate JavaScript code from given file - specified by first argument
        engine.eval(new java.io.FileReader(new File("resources/scripting/example1/script.js").getAbsoluteFile()));
    }
}
